﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xejen.Database.Ef.Sqlite.Demos
{
    /// <summary>
    /// 表示<see langword="Ef"/>框架的SqlServer数据库上下文
    /// </summary>
    /// <see href="https://docs.microsoft.com/zh-cn/ef/ef6/fundamentals/configuring/connection-strings"/>
    public class TestSqliteDbContext : SqliteDbContext
    {
        /// <inheritdoc cref="DataTransferRecordEntity"/>
        public DbSet<DataTransferRecordEntity> DataTransferRecords { get; set; }
        /// <inheritdoc cref="ApiRequestRecordEntity"/>
        public DbSet<ApiRequestRecordEntity> ApiRequestRecords { get; set; }
        /// <inheritdoc cref="ProtocolRecordEntity"/>
        public DbSet<ProtocolRecordEntity> ProtocolRecords { get; set; }

        /// <inheritdoc cref="TestSqliteDbContext"/>
        public TestSqliteDbContext(string connectionString) : base(connectionString)
        {

        }

        /// <inheritdoc cref="TestSqliteDbContext"/>
        /// <param name="existingConnection"><inheritdoc cref="SqlServerDbContext.SqlServerDbContext(DbConnection, bool)" path="/param[@name='existingConnection']"/></param>
        public TestSqliteDbContext(DbConnection existingConnection) : base(existingConnection)
        {
        }

        /// <inheritdoc cref="TestSqliteDbContext"/>
        /// <param name="objectContext"><inheritdoc cref="SqlServerDbContext.SqlServerDbContext(ObjectContext, bool)" path="/param[@name='objectContext']"/></param>
        public TestSqliteDbContext(ObjectContext objectContext) : base(objectContext)
        {
        }

        /// <inheritdoc cref="TestSqliteDbContext"/>
        /// <param name="existingConnection"><inheritdoc cref="SqlServerDbContext.SqlServerDbContext(DbConnection, bool)" path="/param[@name='existingConnection']"/></param>
        /// <param name="contextOwnsConnection"><inheritdoc cref="SqlServerDbContext.SqlServerDbContext(DbConnection, bool)" path="/param[@name='contextOwnsConnection']"/></param>
        public TestSqliteDbContext(DbConnection existingConnection, bool contextOwnsConnection) : base(existingConnection, contextOwnsConnection)
        {

        }

        /// <inheritdoc cref="TestSqliteDbContext"/>
        /// <param name="objectContext"><inheritdoc cref="SqlServerDbContext.SqlServerDbContext(ObjectContext, bool)" path="/param[@name='objectContext']"/></param>
        /// <param name="dbContextOwnsObjectContext"><inheritdoc cref="SqlServerDbContext.SqlServerDbContext(ObjectContext, bool)" path="/param[@name='dbContextOwnsObjectContext']"/></param>
        public TestSqliteDbContext(ObjectContext objectContext, bool dbContextOwnsObjectContext) : base(objectContext, dbContextOwnsObjectContext)
        {
        }

        /// <inheritdoc/>
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);


            //modelBuilder.Entity<Student>().ToTable("Students");
            //modelBuilder.Entity<Student>().Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
        }
    }
}
